//添加目录促销
function addCatalogPromotion(){
	var form=document.mainForm;
	return fnDoAction(form, "addCatalogPromotion");
}
//添加购物车促销
function addShoppingcartPromotion(){
	var form=document.mainForm;
	return fnDoAction(form, "addShoppingcartPromotion");
}
//添加优惠券促销
function addCouponPromotion(){
	var form=document.mainForm;
	return fnDoAction(form, "addCouponPromotion");
}

//对已有结果进行排序,ascValue表示升序时对应的值,descValue表示降序时对应的值
function sortField(linkDOM,ascValue,descValue){
	var jThDOM = $j(linkDOM).parent('th');
	if(jThDOM.hasClass("order1")){
		$j('#storageOrderby').val(descValue);
	}else{
		$j('#storageOrderby').val(ascValue);
	}
	searchPromoRules(false);
}

//搜索规则 isNew标示是否新的搜索,param标示是否自定义参数搜索
function searchPromoRules(isNew,param){
	var postData;
	var url;
	if(isNew){
		if(null==param){
			if(validateSearchCriteria()){
				//有搜索结果搜索
			    postData = $j('#promoRuleSearchCriteria :input').serializeArray();
			    url=__ctxPath+"/sales/promoRule/blank.html?doAction=search&btnSearch=1";
				$j("#promoRuleResults").load(url,postData);
		    }else{
		    	return;
		    }
		}else{
			//新的搜索。全部，上架等
			//有搜索结果搜索
			if(param.status  != undefined){
				$j('#storageStatus').val(""+param.status);
			}
		    postData = $j('#promoRuleResults :input').serializeArray();
		    url=__ctxPath+"/sales/promoRule/blank.html?doAction=search&btnSearch=1";
			$j("#promoRuleResults").load(url,postData);  
		}    
	}else{
		postData = $j('#promoRuleResults :input').serializeArray();
		url=__ctxPath+"/sales/promoRule/blank.html?&doAction=search";
		$j("#promoRuleResults").load(url,postData);  
	} 
	
}


//验证函数
function validateSearchCriteria(){
	if(!validateForm($j('#promoRuleSearchCriteria').get(0))){
    	return false;
   	}
   	return true;
}

//重设搜索条件
function resetSearchCriteria(){
	$("sc_name").value = "";
	$("sc_promoType").selectedIndex = 0;
	$("sc_state").selectedIndex = 0;
}

//刷新列表
function refreshPromoList(){
	searchPromoRules(false);
}
//分页
function fnOnGoToPage(){
	refreshPromoList();
}
//删除多个规则
function multiDeletePromotion(){
	var paraData=$j("#promoRuleListForm :input[name='multiIds']").serializeArray();
	if(paraData.length>0){
		var itemNames = fnGetSelectedItemNames();
		if(confirm( __FMT.common_message_confirmDeleteThis+ " " + itemNames+"?")){
			$j.post(__ctxPath + "/sales/promoRule/blank.html?doAction=multiDelete", paraData, multiDeletePromotionCallback,"json");
		}
	}else{
		alert(__FMT.promoRuleList_selectPromoRule);
	}
}
//删除多个规则回调函数
function multiDeletePromotionCallback(data){
	sysMsg(data.message);
	refreshPromoList();
}

